//
//  CCRObjects.h
//  iHealthEHR
//
//  Created by Joseph Ayo Akinyele on 3/15/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <Security/Security.h>
#import "GoogleHealth.h"
#import "XMLParser.h"
#import "NSData+Base64.h"
#import "CPABEInterface.h"

#define ENCRYPTED_ENTRY @"[!ENCRYPTED ENTRY!]"
#define ENCRYPTED_CELL	@"[Encrypted]"

@interface CCRObject : NSObject {
	NSDate *editDate;
	NSString *item, *description, *ccrsection;
	// original XmlElement
	NSXMLElement *XmlElement;
	// if orig, enc. then plaintext element
	NSXMLElement *plaintextXmlElement;
	// if orig, plaintext then store encrypted version here
	NSXMLElement *encryptedXmlElement;
@private
	// if element is decrypted properly, use this object to store bogus plaintext version
	NSXMLElement *bogusPlaintext;
}

@property (nonatomic, retain) NSDate *editDate;
@property (nonatomic, retain) NSString *item, *description, *ccrsection;
@property (nonatomic, retain) NSXMLElement *XmlElement, *plaintextXmlElement, *encryptedXmlElement;

-(void) initOtherXMLObjects;
-(BOOL) isXMLEntryEncrypted;
+(BOOL) isThisEntryEncrypted:(NSXMLElement *) element;
-(BOOL) isEntryEncrypted;
-(void) encrypt;
-(BOOL) decrypt:(CPABEInterface *) cpabe;
-(BOOL) decryptElementFromGoogleHealth:(CPABEInterface *) cpabe;
-(NSXMLElement *) transformEncryptedForGoogleHealth:(CPABEInterface *) cpabe;
-(NSString *) getABEPolicy:(CPABEInterface *) cpabe with:(BOOL) isGoogle;
-(NSXMLNode *) getEncryptedNode;
-(NSXMLNode *) getEncryptedSource;
-(NSXMLElement *) getPlainText;
-(void) printObject;
+(NSString *) getbogusXML:(NSString *) parent;
+(BOOL) isABEComplete:(NSXMLNode *) node;
+(NSString *) base64Encode:(NSString *) input;
+(NSString *) base64Decode:(NSString *) input;
+(void) popUpNotice:(NSString *) mytitle withMessage:(NSString *) message;

@end
